Add comprehensive event emission for auth-related failures - #57
Open
alberto-crossmint wants to merge 4 commits into
Open
Add comprehensive event emission for auth-related failures#57alberto-crossmint wants to merge 4 commits into
alberto-crossmint wants to merge 4 commits into
Conversation
- Add event structures for auth check failures, signer operations, policy validation, and signature verification - Emit events before returning errors in __check_auth, signer management, policy validation, and signature verification functions - Include detailed context (error type, signer key, operation context) for easy parsing - Follow existing event emission patterns using env.events().publish() - Convert Error enum and SignerKey to Soroban-compatible types (u32 codes and strings) - Add helper functions for error and signer key conversion to maintain consistency Co-Authored-By: Alberto Garc\u00EDa <alberto@paella.dev>
Co-Authored-By: Alberto Garc\u00EDa <alberto@paella.dev>
Contributor
|
Original prompt from Alberto: |
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
- Break long lines in error_to_code_and_message calls to comply with rustfmt - Simplify signer_key_to_string match arms to single-line format - Address all formatting violations identified by cargo fmt --check Co-Authored-By: Alberto Garc\u00EDa <alberto@paella.dev>
- Prefix unused variables with underscores to satisfy clippy lint checks - Resolves clippy errors that were causing CI lint failures Co-Authored-By: Alberto Garc\u00EDa <alberto@paella.dev>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add comprehensive event emission for auth-related failures
Summary
This PR adds comprehensive event emission for authentication-related failures throughout the stellar smart account contract, as requested by @alberto-crossmint. When auth functions fail for any reason, the contract now emits detailed events before returning errors, making it easier to parse and understand failure reasons.
Key Changes:
AuthCheckFailedEvent,SignerOperationFailedEvent,PolicyValidationFailedEvent,SignatureVerificationFailedEvent__check_auth, signer management functions (add_signer,update_signer,revoke_signer), policy validation, signature verification, and constructor validationErrorenums to numeric codes and string messages for Soroban compatibilityTechnical Notes:
#[contracttype]for Soroban serialization compatibilityu32codes (1-11) with string messages for easy parsingformat!macroReview & Testing Checklist for Human
error_to_code_and_message()function are accurate and complete for all Error enum variantsRecommended Test Plan:
Diagram
%%{ init : { "theme" : "default" }}%% graph TD A["contracts/smart-account/src/account.rs"]:::major-edit B["contracts/smart-account/src/lib.rs"]:::minor-edit C["contracts/smart-account/src/auth/policy/time_based.rs"]:::minor-edit D["contracts/smart-account/src/auth/policy/allow_list.rs"]:::minor-edit E["contracts/smart-account/src/auth/signers/ed25519.rs"]:::minor-edit F["contracts/smart-account/src/auth/signers/secp256r1.rs"]:::minor-edit A --> |"exports events"| B A --> |"calls policy validation"| C A --> |"calls policy validation"| D A --> |"calls signature verification"| E A --> |"calls signature verification"| F A --> |"emits events on failure"| G["Event Emission Points:<br/>- __check_auth<br/>- add_signer<br/>- update_signer<br/>- revoke_signer<br/>- __constructor"]:::context subgraph Legend L1["Major Edit"]:::major-edit L2["Minor Edit"]:::minor-edit L3["Context/No Edit"]:::context end classDef major-edit fill:#90EE90 classDef minor-edit fill:#87CEEB classDef context fill:#FFFFFFNotes
format!macro for hex encoding("auth", "failed"),("signer", "failed"),("policy", "failed")for easy filtering